//
//  OneImageTableViewCell.m
//  news
//
//  Created by lanou on 15/12/17.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "OneImageTableViewCell.h"
#import "NewsIntroduction.h"

@implementation OneImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.image_View = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, kWidth / 3.7, kWidth / 5)];
        [self.contentView addSubview:self.image_View];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((kWidth / 3.7 + 20), kWidth / 25, (kWidth - kWidth / 3.7 - 30), 20)];
        [self addSubview:self.titleLabel fontSize:15.0 color:[UIColor blackColor]];
    
        self.digestLabel = [[UILabel alloc] initWithFrame:CGRectMake((kWidth / 3.7 + 20), kWidth / 25 + 20, (kWidth - kWidth / 3.7 - 50), kWidth / 5 + 20 - 50)];
        self.digestLabel.numberOfLines = 0;
        [self addSubview:self.digestLabel fontSize:12.0 color:[UIColor grayColor]];
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10, kWidth / 5 + 20 - 1, kWidth - 20, 1)];
        lineView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)setNewsIntroduction:(NewsIntroduction *)newsIntroduction
{
    if (_newsIntroduction != newsIntroduction) {
        _newsIntroduction = newsIntroduction;
        self.image_View.image = [UIImage imageNamed:@"ic_blank_collect@3x"];
        [self.image_View setImageWithURL:[NSURL URLWithString:newsIntroduction.imgsrc]];
        self.titleLabel.text = newsIntroduction.title;
        self.digestLabel.text = newsIntroduction.digest;
    }
}

- (void)addSubview:(UILabel *)label fontSize:(CGFloat)fontSize color:(UIColor *)color
{
    label.font = [UIFont boldSystemFontOfSize:fontSize];
    label.textColor = color;
    [self.contentView addSubview:label];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
